<?php
namespace Admin\Controller;
use Think\Controller;
class CouponController extends CommonController{
    public function index(){
        $this->list=M("coupon_record a")
        ->join("left join agency_coupon_qrcode b on a.qecode_id=b.qrcode_id")
        ->join('left join agency_coupon_list c on a.coupon_id=c.coupon_id')
        ->join('left join agency_user_list d on a.user_id=d.user_id')
        ->field("a.*,b.qrcode_name,c.coupon_name,d.name")
        ->select();
        $this->display();
    }
    public function edit(){
        $id=I("get.id");
        $data['state']=1;
        if( M('coupon_record')->where(array("record_id"=>$id))->save($data)){
            $this->success("恢复成功","index",1);die;
        }else{
            $this->error("恢复失败","",1);
        }
        // $this->info=M('coupon_record')->where(array("auth_id"=>$id))->find();
        // if (IS_POST){
        //     $data=I('post.');

        //     if(M("coupon_record")->save($data)){
        //         $this->success("更新成功","index",1);die;
        //     }else{
        //         $this->error("更新失败","",1);
        //     }
        // }
        $this->display();
    }
    public  function del(){
        $id=I("get.id");
        $data['state']=0;
        if( M('coupon_record')->where(array("record_id"=>$id))->save($data)){
            $this->success("删除成功","index",1);die;
        }else{
            $this->error("删除失败","",1);
        }


    }
}